import { request } from '@umijs/max';

/** 分页查询数据字典 GET /system/dict/data/page/list */
export async function getDictList(params: API.QueryDictPageParams) {
  return request<API.QueryPageResp<API.Dict>>('/system/dict/data/page/list', {
    method: 'GET',
    params,
  });
}

/** 新增数据字典 POST /system/dict/data/add */
export async function addDict(params: API.Dict) {
  return request<API.Resp>('/system/dict/data/add', {
    method: 'POST',
    data: params,
  });
}

/** 更新数据字典 POST /system/dict/data/update */
export async function updateDict(params: API.Dict) {
  return request<API.Resp>('/system/dict/data/update', {
    method: 'POST',
    data: params,
  });
}

/** 通过ID查询单条数据字典 GET /system/dict/data/get/{id} */
export async function getDictById(id: React.Key) {
  return request<API.Resp<API.Dict>>(`/system/dict/data/get/${id}`, {
    method: 'GET',
  });
}

/** 查询字典下拉框 GET /system/dict/data/list */
export async function getDictSelectList() {
  return request<API.Resp<API.Dict[]>>(`/system/dict/data/list`, {
    method: 'GET',
  });
}

/** 通过ID删除单条数据字典 POST /system/dict/data/delete */
export async function deleteDictById(id: React.Key) {
  return request<API.Resp>(`/system/dict/data/delete`, {
    method: 'POST',
    params: {
      id,
    },
  });
}

/** 批量删除数据字典 POST /system/dict/data/deletes */
export async function deleteDictsByIdList(idList: React.Key[]) {
  return request<API.Resp>(`/system/dict/data/deletes`, {
    method: 'POST',
    data: idList,
  });
}
